<template>
  <div class="songer">
    <div class="container">
      <div class="side">
        <ul class="songerAreaList" v-for="(item, index) in songerArea" :key="index">
          <div class="area">{{item.area}}</div>
          <li class="type"><a href="javascript:;" @click="handleClickSonger(item, 1)">{{item.area}}男歌手</a></li>
          <li class="type"><a href="javascript:;" @click="handleClickSonger(item, 2)">{{item.area}}女歌手</a></li>
          <li class="type"><a href="javascript:;" @click="handleClickSonger(item, 3)">{{item.area}}组合/乐队</a></li>
        </ul>
      </div>
      <div class="content">
        <div class="title">{{title}}</div>
        <ul class="songerList">
          <li class="songerInfo" v-for="item in songerList" :key="item.id">
            <img class="avatarImg" :src="item.picUrl" :alt="item.name">
            <span class="songer">{{item.name}}</span>
            <img class="flag" src="../../assets/logo.png" alt="logo">
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Songer',
  data () {
    return {
      songerArea: [
        {
          area: '华语',
          id: 7
        },
        {
          area: '欧美',
          id: 96
        },
        {
          area: '日本',
          id: 8
        },
        {
          area: '韩国',
          id: 16
        },
        {
          area: '其他',
          id: 0
        }
      ],
      songerList: [],
      songerActive: '全部',
      songerType: -1
    }
  },
  computed: {
    title () {
      return this.songerActive + (this.songerType === 1 ? '男歌手' : this.songerType === 2 ? '女歌手' : this.songerType === 3 ? '组合/乐队' : '')
    }
  },
  methods: {
    handleClickSonger (target, type) {
      this.songerActive = target.area
      this.songerType = type
      this.getSonger(type, target.id)
      console.log(target.area, type)
    },
    async getSonger (type, area) {
      const res = await this.$http.get(`/artist/list?type=${type}&area=${area}&initial=${-1}`)
      this.songerList = res.data.artists
    }
  },
  created () {
    this.getSonger(-1, -1)
  }
}
</script>

<style lang="less" scoped>
.songer{
  margin-top: 33px;
}
.container{
  width: 1100px;
  margin: 0 auto;
  background-color: #ffffff;
   overflow: hidden;
}

.side{
  float: left;
  width: 20%;
  background-color: #f9f9f9;
  box-sizing: border-box;
  padding: 20px;
  .area{
    font-size: 18px;
    font-weight: 600;
  }
  .songerAreaList{
    padding: 20px 0;
    border-bottom: 1px solid #d3d3d3;
    .type{
      margin: 10px 0;
      a{
        color: #333333;
      }
      a:hover{
        text-decoration: underline;
      }
    }
  }
}

.content{
  width: 80%;
  float: left;
  // background-color: blueviolet;
  box-sizing: border-box;
  padding: 20px;
  .title{
    font-size: 18px;
    font-weight: 600;
    padding: 10px 0;
    border-bottom: 2px solid #c20c0c;
  }
  .songerList{
    overflow: hidden;
    width: 100%;
    .songerInfo{
      float: left;
      padding: 20px;
      box-sizing: border-box;
      // background-color: blanchedalmond;
      width: 20%;
      .avatarImg{
        width: 100%;
        height: 104px;
      }
      .songer{
        // 做单行溢出处理
        margin-top: 5px ;
        width: 70%;
        font-size: 14px;
        display: block;
        float: left;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .flag{
        width: 25px;
        vertical-align: middle;
        float: right;
      }
    }
  }
}
</style>
